import 'package:flutter/material.dart';
import 'package:loxen/utils/color.dart';

import 'base_view_model.dart';

class ThemeViewModel extends BaseViewModel {
  ThemeData themeData = getTheme();
  static bool isDarkMode = false;

  changeTheme() {
    isDarkMode = !isDarkMode;
    notifyListeners();
  }

  static getTheme() {
    return ThemeData(
        pageTransitionsTheme: PageTransitionsTheme(builders: {
          TargetPlatform.android: CupertinoPageTransitionsBuilder(),
          TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
        }),
        primaryColor: isDarkMode ? Colours.dark_app_main : Colours.app_main,
        backgroundColor: isDarkMode ? Colours.dark_bg_color : Colours.bg_color,
        primaryTextTheme: TextTheme(
            subtitle1: TextStyle(
                color:
                    isDarkMode ? Colours.dark_text_gray : Colours.text_grey)),
        textTheme: TextTheme(
          //title文本颜色
          subtitle1:
              TextStyle(color: isDarkMode ? Colors.white70 : Colors.white),
          //内容文本颜色
          subtitle2: TextStyle(color: isDarkMode ? Colors.grey : Colors.black),
        ),
        appBarTheme: AppBarTheme(
          elevation: 1,
        ));
  }

  static ThemeData light() {
    return ThemeData(
      textTheme: TextTheme(
          subtitle1: TextStyle(
        color: Colors.white,
      )),
      backgroundColor: Colours.bg_color,
      brightness: Brightness.light,
      primaryColor: Colours.app_main,
      appBarTheme: AppBarTheme(
        elevation: 0,
        textTheme: TextTheme(
          subtitle1: TextStyle(
            color: Colors.white,
          ),
        ),
      ),
    );
  }

  static ThemeData dark() {
    return ThemeData(
      textTheme: TextTheme(
          subtitle1: TextStyle(
        color: Colors.white70,
      )),
      backgroundColor: Colours.dark_bg_color,
      brightness: Brightness.dark,
      primaryColor: Colours.dark_app_main,
      appBarTheme: AppBarTheme(
        elevation: 0,
        textTheme: TextTheme(
            subtitle1: TextStyle(
          color: Colors.white70,
        )),
      ),
    );
  }
}
